package org.example.dao.orderuser;


import org.apache.ibatis.annotations.*;
import org.example.entity.OrderUser;

import java.util.List;

@Mapper
public interface OrderUserMapper {

    @Options(keyProperty = "orderId",useGeneratedKeys = true)
    @Insert("insert into order_system.order_user(open_id, username, phone, address, price, create_time)" +
            "values (#{openId},#{username},#{phone},#{address},#{price},#{createTime})")
    boolean addOrderUser(OrderUser orderUser);

    @Select("select * from order_user where open_id = #{openId} order by order_id desc")
    List<OrderUser> getOrderUserById(String openId);

    @Delete("delete from order_user where order_id = #{orderId}")
    boolean deleteOrderByOrderId(Integer orderId);

    List<OrderUser> listByReason(String orderIdBegin, String orderIdEnd, String username,
                                 String status,String phone, String beginTime, String endTime);

    @Update("update order_user set status = '1' where order_id =#{orderId}")
    boolean orderSend(String orderId);

    @Select("select order_user.status from order_user where order_id = #{orderId}")
    String getOrderUserStatusByOpenId(String orderId);

    @Update("update order_user set status = '2' where order_id = #{orderId}")
    boolean orderComplete(String orderId);
}
